package com.lxiaodd.controller;

import java.util.HashMap;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lxiaodd.pojo.User;

@Controller
@RequestMapping("test")
public class TestController2 {

	/**
	 * json提交
	 * @param u
	 * @return
	 */
	@RequestMapping("tu")
	@ResponseBody
	public HashMap<String, Object> tu(@RequestBody User u){
		HashMap<String, Object> map = new HashMap<>();
		map.put("id", u.getId());
		map.put("name", u.getName());
		map.put("age", u.getAge());
		return map;
	}
	
	/**
	 * form提交
	 * @param u
	 * @return
	 */
	@RequestMapping("tu2")
	@ResponseBody
	public HashMap<String, Object> tu2( User u){
		HashMap<String, Object> map = new HashMap<>();
		map.put("id", u.getId());
		map.put("name", u.getName());
		map.put("age", u.getAge());
		return map;
	}
}
